package com.security.system.serviceImpl;

import com.security.system.service.ExportExcelService;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;

import java.io.FileInputStream;

@Service
public class ExportExcelServiceImpl implements ExportExcelService {

    @Override
    public Workbook exportExcel() throws Exception {
        //加载 Excel 模板
        Resource resource =  new ClassPathResource("excel-template/mode.xlsx");
        FileInputStream fis = new FileInputStream(resource.getFile());
        //根据模板 创建工作薄
        Workbook wb = new XSSFWorkbook(fis);
        //读取工作表
        Sheet sheet = wb.getSheetAt(0);
        return wb;
    }

}
